#!/usr/bin/env node

const log = console.log,
      Router = require('koa-router'),
      router = new Router();

const app = new Koa();



router.prefix('api/tasks');
 
  router.get( '/',async(ctx,next)=>{
    let {page,limit} = ctx.query;
    log(ctx.header['user-agent']);
    log(`得到待办事项列表 page = ${page},limit = ${limit}`);
  
    ctx.body = '查询成功'
  });
  router.post('/',async(ctx,next)=>{
    let {task} = ctx.request.body;
    log(`提交代办事项 task = ${task}`);
    ctx.body = '提交成功'
  });
  router.put(/:id,async(ctx,next)=>{
    
    let {id} = ctx.params;
    let {task} = ctx.request.body;
    log(`修改待办事项 id=${id} task = ${task}`);
    ctx.body = '修改成功'
        
  });
  router.delete(/:id,async(ctx,next)=>{
    
    let {id} = ctx.params;
    log(`删除待办事项 id=${id}`);
    ctx.body = '删除成功'
      
  });

module.exports = router;


